package ru.ssau.university.web.helper;

import java.util.ArrayList;
import java.util.List;

import ru.ssau.university.ejb.api.UniversityServiceLocal;
import ru.ssau.university.persistence.entity.Schedule;
import ru.ssau.university.persistence.entity.Subject;

public class ScheduleRow {
	UniversityServiceLocal universityService;
	private int lessonNum;
	private int week;
	private Long groupId;
	private List<ScheduleWrapper> items;

	public ScheduleRow(int lessonNum, UniversityServiceLocal universityService,
			Long groupId, int week, List<Subject> subjects) {
		this.lessonNum = lessonNum;
		this.universityService = universityService;
		this.groupId = groupId;
		this.week = week;
		initAll(subjects);
	}

	private void initAll(List<Subject> subjects) {
		items = new ArrayList<ScheduleWrapper>();
		for (int dayOfWeek = 0; dayOfWeek < 6; dayOfWeek++) {
			Schedule s = universityService.getSchedule(groupId, week,
					dayOfWeek, lessonNum);
			items.add(new ScheduleWrapper(s, subjects));
		}
	}

	public int getLessonNum() {
		return lessonNum;
	}

	public void setLessonNum(int lessonNum) {
		this.lessonNum = lessonNum;
	}

	public List<ScheduleWrapper> getItems() {
		return items;
	}

	public void setItems(List<ScheduleWrapper> items) {
		this.items = items;
	}

	public int getWeek() {
		return week;
	}

	public void setWeek(int week) {
		this.week = week;
	}

}
